#include "mainwindow.h"
#include <QMenu>
#include <QMenuBar>
#include <QFileDialog>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowTitle(tr("SVG Viewer"));
    creatMenu();
    svgWindow =new SvgWindow;
    setCentralWidget(svgWindow);
}

MainWindow::~MainWindow()
{
}

void MainWindow::creatMenu()
{
    QMenu *fileMenu =menuBar()->addMenu (tr(" 文件")) ;
    QAction *openAct =new QAction(tr(" 打开"),this);
    connect(openAct,&QAction::triggered,this,&MainWindow::slotOpenFile);
    fileMenu->addAction(openAct);
}

void MainWindow::slotOpenFile()
{
    QString name =QFileDialog::getOpenFileName(this, "打开","/","svg files(*.svg)");
    svgWindow->setFile(name);
}

